package com.fsl.springbootatomikos.ao.impl;

import com.fsl.springbootatomikos.ao.UserAo;
import com.fsl.springbootatomikos.domain.Test;
import com.fsl.springbootatomikos.domain.User;
import com.fsl.springbootatomikos.mapper.databases1.UserMapper;
import com.fsl.springbootatomikos.mapper.databases2.TestMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserAoImpl implements UserAo {
	
	private static Logger logger = LoggerFactory.getLogger(UserAoImpl.class);
	
	@Autowired
	private UserMapper userMapper;
	
	@Autowired
	private TestMapper testMapper;

	@Override
	public Integer save() throws Exception {
		userMapper.add(new User("pro", 11));
		testMapper.add(new Test("test"));
		logger.info("save ok");
		return 1;
	}

	@Override
	public void del() throws Exception{
		userMapper.del();
		System.out.println(1/0);
		testMapper.del();
	}
}
